/**
 * 
 */
package edu.sjtu.seda.event;

import java.util.concurrent.ThreadPoolExecutor;

import edu.sjtu.seda.event.Event.STATUS;
import edu.sjtu.seda.threadpool.StageRunner;

/**
 * @author john.zhu
 *
 */
public class EventRejectHandlerImpl implements EventRejectHandler{
	private String name;
	
	public EventRejectHandlerImpl(String name){
		this.name = name;
	}

	@Override
	public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
		if(r instanceof StageRunner){
			((StageRunner) r).getEvent().setStatus(STATUS.REJECTED);
			log.error("Queue {0} is full and event {1} will be rejected.",name,((StageRunner) r).getEvent().getUID());
		}
	}

}
